using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class v_SystemMenuMap : EntityTypeConfiguration<v_SystemMenu>
    {
        public v_SystemMenuMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(t => t.DisplayName)
                .HasMaxLength(255);

            this.Property(t => t.NavigatorUrl)
                .HasMaxLength(200);

            this.Property(t => t.Description)
                .HasMaxLength(200);

            this.Property(t => t.ControllerName)
                .HasMaxLength(100);

            this.Property(t => t.ActionName)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("v_SystemMenu");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.DisplayName).HasColumnName("DisplayName");
            this.Property(t => t.NavigatorUrl).HasColumnName("NavigatorUrl");
            this.Property(t => t.ParentId).HasColumnName("ParentId");
            this.Property(t => t.IsShow).HasColumnName("IsShow");
            this.Property(t => t.IsActive).HasColumnName("IsActive");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.ControllerName).HasColumnName("ControllerName");
            this.Property(t => t.ActionName).HasColumnName("ActionName");

            // Relationships
            this.HasOptional(t => t.v_SystemMenu2)
                .WithMany(t => t.v_SystemMenu1)
                .HasForeignKey(d => d.ParentId);

        }
    }
}
